package com.swh.controller.business;

import com.github.pagehelper.PageInfo;
import com.swh.entity.AppVersion;
import com.swh.service.AppVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/14 14:41
 * @Version: 1.0
 */
@Controller
@RequestMapping("/guguanjia/app")
public class AppVersionController {

    @Autowired
    private AppVersionService appVersion;

    @RequestMapping("/index")
    public String login() {
        return "/app/index";
    }

    //查询所有
    @RequestMapping("/findAll/{pageNum}/{pageSize}")
    @ResponseBody
    public PageInfo<AppVersion> findAll(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize) {
        return appVersion.findPage(pageNum, pageSize);
    }

    @RequestMapping("/toUpdate")
    public String tuUpdate() {
        return "/app/update";
    }


    //添加
    @RequestMapping(value = "insert", method = RequestMethod.POST)
    @ResponseBody
    public void insert(@RequestBody AppVersion app) {
        app.setCreateDate(new Date());
        app.setUpdateDate(new Date());
        app.setDelFlag("0");
        appVersion.insert(app);
    }


    //删除//修改
    @ResponseBody
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    public void updateById(@RequestBody AppVersion app) {
        appVersion.update(app);
    }





    //根据id查询并且回写数据
    @ResponseBody
    @RequestMapping("/get")
    public Object get(Integer id){
        AppVersion byId = appVersion.findById(id);
        System.out.println(byId);
        return byId;
    }





}
